#include"gateway_server.hpp"
#include<gflags/gflags.h>

DEFINE_bool(run_mode,false,"程序运行的模式,false-调试,true-发布");
DEFINE_string(log_file,"","发布模式下,用于指定日志输出的文件");
DEFINE_int32(log_level,0,"发布模式下,用于指定日志输出等级");

DEFINE_int32(http_port,9000,"http服务监听端口");
DEFINE_int32(websocket_port,9001,"websocket服务监听端口");

DEFINE_string(registry_host,"http://127.0.0.1:2379","服务注册中心地址");
DEFINE_string(base_service,"/service","服务监控根目录");
DEFINE_string(file_service,"/service/file_service","文件存储子服务");
DEFINE_string(speech_service,"/service/speech_service","语音识别子服务");
DEFINE_string(user_service,"/service/user_service","用户管理子服务");
DEFINE_string(transmite_service,"/service/transmite_service","转发管理子服务");
DEFINE_string(message_service,"/service/message_service","消息存储子服务");
DEFINE_string(friend_service,"/service/friend_service","好友管理子服务");

DEFINE_string(redis_host,"127.0.0.1","Redis服务器的IP地址信息");
DEFINE_int32(redis_port,6379,"Redis服务器的端口号");
DEFINE_int32(redis_db,0,"Redis库的编号默认是0号");
DEFINE_bool(redis_keep_alive,true,"Redis是否进行长连接保活");

int main(int argc,char* argv[])
{
    google::ParseCommandLineFlags(&argc,&argv,true);
    wzl::init_logger(FLAGS_run_mode,FLAGS_log_file,FLAGS_log_level);
    
    wzl::GatewayServerBuilder gsb;

    gsb.make_redis_object(FLAGS_redis_host,FLAGS_redis_port,FLAGS_redis_db,FLAGS_redis_keep_alive);

    gsb.make_discovery_object(FLAGS_registry_host,FLAGS_base_service,FLAGS_file_service,FLAGS_speech_service,\
        FLAGS_user_service,FLAGS_transmite_service,FLAGS_message_service,FLAGS_friend_service);

    gsb.make_server_object(FLAGS_websocket_port,FLAGS_http_port);

    auto server = gsb.build();
    server->start();
    return 0;
}